var nf = sm("do_Notification");
var do_Page = sm("do_Page");
var deviceone = require("deviceone");
var activityUtil = require("helper/activity");
var circleHelper = require("helper/circle");
var activityUrl = require("url/activity");
var helperOpen = require("helper/open");
var qqHttp = require("helper/httpSilence");
var bizzType = require("helper/bizzType");
var pubUrl = require("url/pub");
var dialog = sm("do_Dialog");
var deviceHelper = require("helper/device");
var signUsersHttp = activityUrl.url.sign.littlePage;

// UI
var root = ui("$");
var linearLayout = ui("linearLayout");
var do_ALayout_27 = ui("do_ALayout_27");
var aLayoutMap = ui("aLayoutMap");
var gridViewResumeImg = ui("gridViewResumeImg");
var labelName = ui("labelName");
var labelTime = ui("labelTime");
var do_ALayout_21 = ui("do_ALayout_21");
var gridViewSignUsers = ui("gridViewSignUsers");
var labelCost=ui("labelCost");
var labelAddress=ui("labelAddress");
var labelSignCount=ui("labelSignCount");
var aLayoutShowSign=ui("aLayoutShowSign");
var do_ALayout_12=ui("do_ALayout_12");
var labelResume = ui("labelResume");
// 设置数据绑定的映射关系
root.setMapping({ // 此处的Mapping只能设置在 RootView 上 ;
	"labelCost.text" : "showCost",
	"labelCost.tag":"status",
	"labelSignCount.text":"signCount",
	"do_ALayout_21.tag" : "signCount",
	"imageViewLogo.source" : "pathLogo",
	"imageViewLogo.tag":"bigPathLogo",
	"linearLayout.tag" : "type",
	"labelName.text" : "name",
	"labelName.tag" : "x",
	"labelTime.tag" : "y",
	"labelTime.text" : "showTime",
	"labelAddress.text" : "address",
	"labelAddress.tag":"showStatus",
	"imageViewSponsorLogo.source" : "sponsorLogo",
	"labelSponsorName.text" : "sponsorName",
	"labelResume.text" : "resume",
	"gridViewResumeImg.items" : "imgItems",
	"gridViewResumeImg.tag" : "bigImgItems",
	"gridViewResumeImg.visible" : "hasImg",
	"do_ALayout_27.tag" : "sponsorId",
	"do_ALayout_12.tag" : "id",
	"gridViewSignUsers.items":"signList",
	"do_ALayout_25.tag":"bizzId"
});
root.on("dataRefreshed", function() {
	if (do_ALayout_21.tag <= 0) {//报名人数
		do_ALayout_21.visible = false;
	} else {
		do_ALayout_21.visible = true;
	}
});

// 图片浏览注册事件
aLayoutMap.on("touch", function(data) {
	helperOpen.open("source://view/area/showMapMarkers.ui", {
		x : labelName.tag,
		y : labelTime.tag
	});
})
// 图片浏览注册事件
gridViewResumeImg.on("touch", function(data) {
	helperOpen.open("source://view/reuse/imgBrowser.ui", {
		imgDatas :gridViewResumeImg.tag,index:data
	});
})
do_ALayout_12.on("touch", function(data) {
	var jsonImgs=[{source:ui("imageViewLogo").tag}];
	helperOpen.open("source://view/reuse/imgBrowser.ui", {
		imgDatas :JSON.stringify(jsonImgs),index:0
	});
})

ui("do_ALayout_25").on("touch", function(data) {
	if(ui("linearLayout").tag=="2"){
		circleHelper.toCircleDetail(ui("do_ALayout_25").tag,ui("labelSponsorName").text);
	}
})
// 访问他、她的资料
do_ALayout_27.on("touch", function(data) {
	if(activityUtil.type.COMMUNIty==linearLayout.tag){
		helperOpen.openPersonal(this.tag);
	}
});
aLayoutShowSign.on("touch", function(data) {
	helperOpen.open("source://view/activity/sign/list/main.ui",{"activityId" : do_ALayout_12.tag});
});

do_Page.on("activity_sign_refash", function(data, e) {
	labelSignCount.text=parseInt(labelSignCount.text)+1;
	do_ALayout_21.visible = true;
	signUsers();
});
function signUsers() {
	var params = {
		"activityId" :do_ALayout_12.tag,
		"page" : 1
	};
	qqHttp.post(signUsersHttp, params, function(data) {
		gridViewSignUsers.items=data.page.content;
	})
}

/*复制文字*/
var layoutResume = ui("layoutResume");
layoutResume.on("touch","",300,function(){
	var datas = {
		"text":	labelResume.text
	}
	var osType = deviceHelper.getOsType();
	var dialogHref = osType==="2"?"source://view/reuse/copyTextIos.ui":"source://view/reuse/copyText.ui";
	dialog.open(dialogHref, datas, function(data, e) {  
	});
});